<template>
  <div>
    <header>
      <button @click="back">
        返回
      </button>
      {{ detailInfo.title }}
    </header>
    <main>
      <img width="100%" height="240px" :src="detailInfo.img" alt="">
    </main>
  </div>
</template>

<script>
import axios from 'axios'
export default {
    data() {
      return {
        detailInfo: {}
      }
    },
    created() {
        axios.get('/getDetail', {
          params: {
            id: this.$route.query.id
          }
        }).then(res => {
          this.detailInfo = res.data
        })

        // this.$router  
        // this.$route   当前页面的路由信息
        // console.log(this.$route.query.id)
    },
    methods: {
      back() {
        // 返回
        this.$router.back()
      }
    }
}
</script>

<style>
</style>